<?php /*a:3:{s:53:"D:\projects\junhe\app\admin\view\attribute\index.html";i:1741925083;s:60:"D:\projects\junhe\app\admin\view\..\..\admin\view\table.html";i:1740136709;s:54:"D:\projects\junhe\app\admin\view\attribute\search.html";i:1742662847;}*/ ?>
<div class="layui-card">
    
    <?php if(!(empty($title) || (($title instanceof \think\Collection || $title instanceof \think\Paginator ) && $title->isEmpty()))): ?>
    <div class="layui-card-header">
        <span class="layui-icon font-s10 color-desc margin-right-5">&#xe65b;</span><?php echo htmlentities((isset($title) && ($title !== '')?$title:''),ENT_QUOTES); ?>
        <div class="pull-right">

<button data-modal='<?php echo url("add"); ?>' data-title="添加" class='layui-btn layui-btn-sm layui-btn-primary'>添加</button>

</div>
    </div>
    <?php endif; ?>
    <div class="layui-card-line"></div>
    <div class="layui-card-body">
        <div class="layui-card-table">
            
<div class="think-box-shadow">
    <fieldset>

    <legend>条件搜索</legend>

    <form class="layui-form layui-form-pane form-search" action="<?php echo sysuri(); ?>" onsubmit="return false" method="get" autocomplete="off">
        <div class="layui-form-item layui-inline">

            <label class="layui-form-label">属性名称</label>

            <label class="layui-input-inline">

                <input name="name" value="<?php echo htmlentities((isset($get['name']) && ($get['name'] !== '')?$get['name']:''),ENT_QUOTES); ?>" placeholder="请输入名称" class="layui-input">

            </label>

        </div>

        <div class="layui-form-item layui-inline">

            <label class="layui-form-label">属性类型</label>

            <label class="layui-input-inline">

                <select name="types" id="">
                    <option value="" >全部</option>
                    <option value="input" >文本</option>
                    <option value="select">下拉选择</option>
                    <option value="checkbox">多选</option>
                </select>

            </label>

        </div>

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">产品分类</label>
            <div class="layui-input-inline">
                <select class="layui-select"  name="cate_id" lay-search>
                    <option value="">选择分类</option>
                    <?php foreach($parent_cate as $cate): ?>
                        <option <?php if(isset($vo['parent_id']) and $vo['parent_id'] == $cate['id']): ?> selected<?php endif; ?> disabled value="<?php echo htmlentities($cate['id'],ENT_QUOTES); ?>"><?php echo htmlentities((isset($cate['title']) && ($cate['title'] !== '')?$cate['title']:''),ENT_QUOTES); ?></option>
                        <?php foreach($cate['child_cate_2'] as $cate2): if($cate2 === end($cate['child_cate_2'])): ?>
                                <option <?php if(isset($vo['cate_id']) and $vo['cate_id'] == $cate2['id']): ?> selected<?php endif; ?>  disabled value="<?php echo htmlentities($cate2['id'],ENT_QUOTES); ?>">╚ <?php echo htmlentities((isset($cate2['title']) && ($cate2['title'] !== '')?$cate2['title']:''),ENT_QUOTES); ?></option>
                            <?php else: ?>
                                <option <?php if(isset($vo['cate_id']) and $vo['cate_id'] == $cate2['id']): ?> selected<?php endif; ?> disabled  value="<?php echo htmlentities($cate2['id'],ENT_QUOTES); ?>">╠ <?php echo htmlentities((isset($cate2['title']) && ($cate2['title'] !== '')?$cate2['title']:''),ENT_QUOTES); ?></option>
                            <?php endif; foreach($cate2['child_cate_3'] as $cate3): if($cate3 === end($cate2['child_cate_3'])): ?>
                                    <option <?php if(isset($vo['cate_id']) and $vo['cate_id'] == $cate3['id']): ?> selected<?php endif; ?> value="<?php echo htmlentities($cate3['id'],ENT_QUOTES); ?>"> └─ <?php echo htmlentities((isset($cate3['title']) && ($cate3['title'] !== '')?$cate3['title']:''),ENT_QUOTES); ?></option>
                                <?php else: ?>
                                    <option <?php if(isset($vo['cate_id']) and $vo['cate_id'] == $cate3['id']): ?> selected<?php endif; ?> value="<?php echo htmlentities($cate3['id'],ENT_QUOTES); ?>"> ├─ <?php echo htmlentities((isset($cate3['title']) && ($cate3['title'] !== '')?$cate3['title']:''),ENT_QUOTES); ?></option>
                                <?php endif; ?>
                            <?php endforeach; ?>
                        <?php endforeach; ?>
                    <?php endforeach; ?>
                </select>
                
            </div>
        </div>


        <div class="layui-form-item layui-inline">

            <input type="hidden" name="type" value="<?php echo htmlentities((isset($type) && ($type !== '')?$type:'index'),ENT_QUOTES); ?>">

            <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>

        </div>

    </form>

</fieldset>
    <table id="RoleTable" data-url="<?php echo request()->url(); ?>" data-target-search="form.form-search"></table>
</div>

        </div>
    </div>
    
<script>
    $(function () {
        // 初始化表格组件
        $('#RoleTable').layTable({
            even: true,
            skin : "line",
            limit : 15,
            size : 'lg',
            sort: {field: 'id', type: 'desc'},
            cols: [[
                // {checkbox: true, fixed: true},
                {field: 'id', title: '<?php echo lang("ID"); ?>', align: 'center', width: 100, sort: true,},
                {field: 'name', title: '<?php echo lang("产品分类"); ?>', align: 'center',templet: function(d){
                    return d.cates? d.cates.title : '无';
                }},
                {field: 'name', title: '<?php echo lang("属性名称"); ?>', align: 'center'},
                {field: 'type', title: '<?php echo lang("属性类型"); ?>', align: 'center', templet: function(d){
                    if (d.type === 'input') {
                        return '文本';
                    } else if (d.type === 'select') {
                        return '下拉选择';
                    }  else if (d.type === 'checkbox') {
                        return '多选';
                    }else {
                        return '未知类型';
                    }
                }},
                {field: 'values', title: '<?php echo lang("属性值"); ?>', align: 'center', templet: function (d) {
                    var html = '';
                    if (Array.isArray(d.values)) {
                        d.values.forEach(function (item) {
                            html += item.value + ' ';
                        });
                    }
                    return html.trim(); // 去除末尾空格
                }},
                {field: 'sort', title: '<?php echo lang("排序"); ?>', align: 'center', width: 100, sort: true,},
                {toolbar: '#toolbar', title: '<?php echo lang("操作面板"); ?>', align: 'center', minWidth: 210, fixed: 'right'},
            ]]
        });


    });

</script>
<!-- 数据操作工具条模板 -->
<script type="text/html" id="toolbar">

    <a data-title="修改" class="layui-btn  layui-btn-sm layui-btn-warm" data-modal='<?php echo url("edit"); ?>?id={{d.id}}''>编辑</a>
    <a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="确定删除吗?" data-action="<?php echo url('remove'); ?>" data-value="id#{{d.id}}">删除</a>

</script>

</div>